<%--
  Created by IntelliJ IDEA.
  User: cloudoer
  Date: 2018/4/13
  Time: 17:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<style type="text/css">
    .article_add_div {
        margin: 20px auto;
    }
</style>
<div class="layui-row">
    <form id="article_add_form" class="layui-form layui-form-pane" method="post">
        <input type="hidden" id="article_add_contents" name="text"/>
        <input type="hidden" id="article_add_id" name="id">
        <input type="hidden" id="article_add_imageURL" name="image">
        <div class="layui-col-md3" style="height: 100%;padding: 20px 10px;">
            <div class="article_add_div">
                <input id="article_add_title" type="text" name="title" autocomplete="off" lay-verify="required"
                       class="layui-input" placeholder="文章标题">
            </div>
            <div class="article_add_div">
                <select id="article_add_type" name="typeid" lay-filter="aihao"></select>
            </div>
            <div class="article_add_div">
                <button type="button" class="layui-btn" id="article_add_image">
                    <i class="layui-icon">&#xe67c;</i>首页图片(用于在列表显示)
                </button>
            </div>
            <div class="article_add_div">
                <input id="article_add_source" type="text" name="source" autocomplete="off" lay-verify="required"
                       class="layui-input" placeholder="来源">
            </div>
            <div class="article_add_div">
                <input id="article_add_ranking" type="text" name="ranking" autocomplete="off" lay-verify="required"
                       class="layui-input" placeholder="站长推荐排名">
            </div>

            <div class="article_add_div" style="text-align: center;">
                <button class="layui-btn" lay-submit lay-filter="article_add_btn">立即提交</button>
            </div>
        </div>
        <div class="layui-col-md9" style="height: 100%;">
            <textarea id="kindEditor" style="width: 100%;height: 535px;"></textarea>
        </div>
    </form>
</div>

<script type="text/javascript">
    var _article_add_js = {
        id:null,
        editor1: null,
        text:null,
        imageURL: null,
        init: function () {
            $('#article_add_id').val(_article_add_js.id);
            $.post('/type/getAll.action',function (data, status) {
                if (data.data != null){
                    $('#article_add_type').html('');
                    var type_html = '';
                    for (var i = 0; i < data.data.length; i++){
                        type_html += '<option value="'+data.data[i].id+'">'+data.data[i].name+'</option>';
                    }
                    $('#article_add_type').append(type_html);
                    _admin_article_js.form.render('select');
                }
            });
        },
        kindeditor: function(){
            _article_add_js.editor1 = KindEditor.create('#kindEditor', {
                uploadJson : 'article/image.action?id='+_article_add_js.id,
                filePostName: 'image',
                resizeType : 0,
                items: ['source', 'undo', 'redo',  'preview', 'code',  'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript',
                    'clearhtml', 'quickformat','formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image', 'table', 'hr', 'emoticons',
                    'baidumap', 'pagebreak','anchor', 'link', 'unlink', 'fullscreen'],
            });
            _article_add_js.editor1.html(_article_add_js.text);
        }
    }

    var article_add_app = (function () {
        $(function () {
            _article_add_js.init();
            _article_add_js.kindeditor();
        });
    })();
</script>